package org.weishe.fof;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Reducer;

public class FOFReducer extends Reducer<FOF, IntWritable, FOF, IntWritable> {

	private IntWritable s = new IntWritable();

	@Override
	protected void reduce(FOF key, Iterable<IntWritable> values,
			Reducer<FOF, IntWritable, FOF, IntWritable>.Context context) throws IOException, InterruptedException {
		boolean flag = false;
		int sum = 0;
		for (IntWritable i : values) {
			if (i.get() == 2) {
				flag = true;
				break;
			}
			sum++;
		}
		if (!flag) {
			s.set(sum);
			context.write(key, s);
		}
	}
}
